/************************************
 * created by Tonk (tonk@ctonk.com) *
 ************************************/

// debug.cpp

/* This is a simple header file that was designed
 * to make... well... debugging easier (what a surprise!)
 * It's also easy to turn on and off. To use it you need
 * to write:
 *  1) #define DEBUG
 *  2) #include "debug.cpp"
 * But to simply remove these two lines, your compiler
 * will yell because you because you have undefined macros
 * and such in your code. Simply comment out line one as
 * so:
 *  1) //#define DEBUG
 *  2) #include "debug.cpp"
 * Using an #ifdef construct, your compiler will turn all
 * instances of these macros into nothing if DEBUG isn't
 * defined.
 *
 * Note: This only works with Winblows and was tested with
 *       MSVS C++ .NET 2003; If you are on a different system
 *       and the colors don't work, you can remove them and
 *       all should be well and good. Just redefine the cc_
 *       macros to nothing.
 *
 * Happy Hunting!
 */

#include <iostream>
#include <Windows.h>

// Define output color macros.
#define ccb SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ),  1 )
#define ccg SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ),  2 )
#define ccc SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ),  3 )
#define ccr SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ),  4 )
#define ccm SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ),  5 )
#define ccy SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ),  6 )
#define ccx SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ),  7 )
#define ccw SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ),  8 )
#define ccB SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ),  9 )
#define ccG SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 10 )
#define ccC SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 11 )
#define ccR SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 12 )
#define ccM SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 13 )
#define ccY SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 14 )
#define ccW SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 15 )

// Inclusion guards
#ifndef H_DEBUGGER
#define H_DEBUGGER


#ifdef DEBUG // Debug mode

	#define TYPE(x);	std::cout << "Variable "; ccG; std::cout << #x; ccx; std::cout << " is type "; ccg;	\
						std::cout << typeid(x).name(); ccx; std::cout << '.' << std::endl;
	#define PRINT(x);	std::cout << "Print "; ccG; std::cout << #x; ccx; std::cout << " holds the value "; ccY;	\
						std::cout << (x); ccx; std::cout << '.' << std::endl;
	#define ASSERT(x);	std::cout << "Assert "; ccC; std::cout << #x; ccx; std::cout << " resolves ";	\
						if (x) { ccW; std::cout << "true"; } else { ccR; std::cout << "false"; } ccx;		\
						std::cout << '.' << std::endl;
	#define CHECK(x);	std::cout << "Check: "; ccG; std::cout << #x; ccx; std::cout << "    Type: "; ccg;			\
						std::cout << typeid(x).name(); ccx; std::cout << "    Value: "; ccY; std::cout << x; ccx;	\
						std::cout << "    Truth: "; if (x) { ccW; std::cout << "true"; } else { ccR;			\
						std::cout << "false"; } ccx; std::cout << std::endl;

#else // Non-debugging mode

	#define TYPE(x);
	#define PRINT(x);
	#define ASSERT(x);
	#define CHECK(x);

#endif // #ifdef DEBUG clause

#endif // #ifndef H_DEBUGGER